Repository navigation
Fetch Trivy directly rather than through setup-trivy - #1
Merged
Merged
Conversation
setup-trivy resolves a tag by making one unauthenticated, un-retried request to github.com and reporting any non-200 as "unable to find <tag>", so a rate-limited moment arrives looking like a deleted release. A plaid job installed v0.70.0 successfully twice and lost the third attempt forty seconds later; the error named the pin rather than the network, which sent the reader after the wrong thing entirely. A release asset URL needs no tag lookup. The install now downloads the tarball directly with curl --retry and verifies it against this repo's committed copy of the release checksums. The version also names the install directory, which makes an earlier invocation in the same job visible: a repo scanning several requirements files installs Trivy once rather than once per file, so the seven lookups that job made become none. The tarball is what gets cached, and the verification runs on a cache hit as well as a fresh download. A cache entry is written by anyone who can run a workflow on the repo, so a Trivy trusted on sight is a scanner someone else chose -- and one that fabricated a clean report would satisfy the completeness check too, by reading the very same dist-info the check counts. setup-trivy skipped its own checksum on a cache hit for the same reason it skipped the download; this closes that path rather than reproducing it. The checksums are committed rather than fetched: pulled from the network beside the tarball they would vouch for transit only, and read from the cache they would be chosen by whoever wrote the cache. trivy-version must therefore name a release whose checksums are committed here, which makes a scanner bump a reviewed change rather than a silent one. `latest` is refused. It was never a sensible thing for a compliance gate to track, and there is no longer a tag to resolve. Trivy is unpacked via mktemp and mv, so the install directory either has no binary or a whole verified one -- never a half-extracted one that the same-job check would read as installed. The end-to-end job now calls the action twice. The repeat invocation is a real code path -- it is what `uv venv --clear` exists for, and what decides whether Trivy installs once or once per file -- and nothing covered it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016wvVVoc2oj2bof9gmq6ZED
rad-pat
force-pushed
the
trivy-install-without-tag-lookup
branch
from
September 7, 2026 16:34
b45c307 to
4ad2886
Compare
rad-pat
marked this pull request as ready for review
September 7, 2026 18:35
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The failure
A plaid license job failed with:
The message is a red herring.
v0.70.0was never gone — it returns 200 today, and the same job installed it successfully twice before losing the third attempt forty seconds later:found version: 0.70.0found version: 0.70.0unable to find 'v0.70.0'setup-trivyshells out to Trivy'scontrib/install.sh, which resolves a tag like this:Unauthenticated, no retry, no token. A rate-limited moment arrives looking like a deleted release, and the error points at the version pin rather than the network.
Two things made it likely rather than rare: the action ran
setup-trivyon every invocation, and plaid calls it seven times in one job — whilesetup-trivy'scacheinput defaults tofalse, which we never overrode. Seven unauthenticated lookups and seven tarball downloads per run, from a shared runner IP.The change
A release asset URL needs no tag lookup, so the action installs Trivy itself:
curl --retry 5 --retry-delay 2 --retry-all-errors --fail.license-check/trivy-checksums.txt— the release's own checksums file, committed here.trivy-tarball-<version>-<os>-<arch>.Verification runs on every path, including a cache hit
This is the part worth reviewing. A cache entry is written by anyone who can run a workflow on the repo, so a Trivy trusted on sight is a scanner someone else chose — and one that fabricated a clean report would satisfy
check_licenses.py's completeness check too, by reading the very same.dist-infothe check counts.setup-trivyskipped its own checksum on a cache hit for the same reason it skipped the download. This closes that path rather than reproducing it. The tarball is what gets cached precisely because it is the thing the committed checksums can vouch for.The checksums are committed rather than fetched: pulled from the network beside the tarball they would vouch for transit only; read from the cache they would be chosen by whoever wrote the cache. So
trivy-versionmust name a release whose checksums live here — which makes a scanner bump a reviewed change rather than a silent one, consistent with why the version was pinned in the first place.Trivy is unpacked via
mktemp+mv, so the install dir either has no binary or a whole verified one — never a half-extracted one the same-job check would read as installed.Verified
Step scripts run against real Linux (WSL), not eyeballed:
OK, binary-rwxr-xr-x,Version: 0.70.0installed=true, short-circuitsVersion: 0.70.0FAILED, refused, no binary left behindlatest/ unknown archPlus a green CI run on the previous revision that showed the real-runner behaviour: cache miss → save → invocation 2 logged no cache lines and no download, then scanned all 9 packages 0.9s later.
The end-to-end job now calls the action twice. The repeat invocation is a real code path — it is what
uv venv --clearexists for, and what decides whether Trivy installs once or once per file — and nothing covered it.This is not a version bump
The pin stays at
v0.70.0. Bumping would not have fixed this: every version resolves through the same flaky lookup, andlatestis worse, sincesetup-trivyrefuses to cache it. Trivy is on 0.74.0 now and that is worth doing as its own reviewed decision — thediagnosticsinput exists for exactly that.For a reviewer
trivy-version: latestnow fails fast. Nothing in the org appears to pass it.trivy-versionnow also needs that release's checksums committed here. Deliberate; it fails loudly, not quietly.setup-trivy: itsgithub-server-url/tokeninputs (GHES only) and thecontrib/*.tpltemplates it staged beside the binary. We only use--format json. Noted in the README.v1tag moving to reach the ten repos on@v1.🤖 Generated with Claude Code
https://claude.ai/code/session_016wvVVoc2oj2bof9gmq6ZED